<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>R-WebEmbedded - 在线串口助手</title>
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"
            integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
        <link rel="stylesheet" href="css/serial_body.css">
        <link rel="icon" href="imgs/logo.png">
    </head>

    <body>
        <header class="main_head bd-header py-3 d-flex align-items-stretch border-bottom">
            <div class="container-fluid d-flex align-items-center">
                <h1 class="d-flex align-items-center fs-4 text-white mb-0">
                    <a href="http://ricechen0.gitee.io/r-web-embedded">
                        <img src="imgs/logo.png" width="35" height="30" class="me-3" alt="WebEmbedded"> 
                    </a>
                    <a>R-WebEmbedded - 在线串口助手</a>
                </h1>
                <span class="main_link ms-auto">
                    <a href="https://www.youyeetoo.com" target="_blank" class="link-light">
                        <img src="imgs/youyeetoo.png" width="30" height="30">
                        youyeetoo官网
                    </a>
                    <a href="https://github.com/RiceChen0" target="_blank" class="link-light">
                        <img src="imgs/github_logo.png" width="30" height="30">
                        博主github
                    </a>
                    <a href="https://gitee.com/RiceChen0" target="_blank" class="link-light">
                        <img src="imgs/gitee_logo.png" width="30" height="30">
                        博主gitee
                    </a>
                    <a href="https://gitee.com/itldg/web-serial-debug" target="_blank" class="link-light">
                        工具原作者：老大哥
                    </a>
                </span>
            </div>
        </header>

        <div id="main" class="d-flex">
            <div id="serial-options" class="col-auto m-0 bg-light sidebar">
                <div class="collapse show p-2 float-start">
                    <div class="input-group mb-3">
                        <span class="input-group-text">波特率</span>
                        <input type="number" id="serial-baud" class="form-control" placeholder="选择波特率" value="115200"
                            list="baud-list">
                        <datalist id="baud-list">
                            <option>4800</option>
                            <option>7200</option>
                            <option>9600</option>
                            <option>14400</option>
                            <option>19200</option>
                            <option>28800</option>
                            <option>38400</option>
                            <option>56000</option>
                            <option>57600</option>
                            <option>76800</option>
                            <option>115200</option>
                            <option>230400</option>
                            <option>460800</option>
                        </datalist>
                    </div>

                    <div class="input-group mb-3">
                        <span class="input-group-text">数据位</span>
                        <select class="form-select" id="serial-data-bits">
                            <option>8</option>
                            <option>7</option>
                        </select>
                    </div>

                    <div class="input-group mb-3">
                        <span class="input-group-text">停止位</span>
                        <select class="form-select" id="serial-stop-bits">
                            <option>1</option>
                            <option>2</option>
                        </select>
                    </div>

                    <div class="input-group mb-3">
                        <span class="input-group-text">校验位</span>
                        <select class="form-select" id="serial-parity">
                            <Option value="none">None</Option>
                            <Option value="even">Even</Option>
                            <Option value="odd">Odd</Option>
                        </select>
                    </div>

                    <div class="input-group mb-3">
                        <span class="input-group-text">缓冲区</span>
                        <input type="number" id="serial-buffer-size" class="form-control" placeholder="缓冲区大小"
                            list="buffer-size-list" max="1677216" value="1024">
                        <datalist id="buffer-size-list">
                            <option>255</option>
                            <option>512</option>
                            <option>1024</option>
                            <option>2048</option>
                            <option>4096</option>
                            <option>8192</option>
                        </datalist>
                    </div>

                    <div class="input-group mb-3">
                        <span class="input-group-text">流控制</span>
                        <select class="form-select" id="serial-flow-control">
                            <Option value="none">None</Option>
                            <Option value="hardware">HardWare</Option>
                        </select>
                    </div>

                    <div class="d-flex mt-2">
                        <button class="btn btn-secondary me-3" id="serial-select-port">选择串口</button>
                        <button class="btn btn-primary flex-grow-1" id="serial-open-or-close">打开串口</button>
                    </div>

                    <div id="serial-status" class="mt-2">
                        <div class="alert alert-info" role="alert">
                            未选择串口
                        </div>
                    </div>
                </div>
                <button class="toggle-button float-end" title="隐藏/打开边栏">
                    <i class="bi bi-chevron-compact-left"></i>
                </button>

            </div>
            <div class="clear"></div>
            <div id="log-main" class="flex-fill px-md-2">
                <div
                    class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-1 pb-1 mb-1 flex-shrink-0">
                    <h1 class="h3">串口日志</h1>

                    <div class="btn-toolbar">
                        <div class="input-group input-group-sm me-2">
                            <span class="input-group-text">分包超时</span>
                            <input type="number" id="serial-timer-out" class="form-control" placeholder="0不分包" value="50"
                                style="width: 100px;" />
                        </div>

                        <div class="input-group input-group-sm me-2">
                            <span class="input-group-text">日志类型</span>
                            <select class="form-select" id="serial-log-type" style="width: 120px;">
                                <Option value="hex&ascii">全部</Option>
                                <Option value="hex">Hex</Option>
                                <Option value="ascii">ASCII</Option>
                            </select>
                        </div>

                        <div class="btn-group">
                            <button class="btn btn-sm btn-outline-secondary" id="serial-auto-scroll">自动滚动</button>
                            <button class="btn btn-sm btn-outline-secondary" id="serial-clear">清空</button>
                            <button class="btn btn-sm btn-outline-secondary" id="serial-copy">复制</button>
                            <button class="btn btn-sm btn-outline-secondary" id="serial-save">导出</button>
                        </div>
                    </div>
                </div>
                <div id="serial-logs" class="flex-grow-1 border border-2 rounded mb-2"></div>
                <div class="flex-shrink-0 mb-2">
                    <textarea class="form-control" rows="3" id="serial-send-content" style="resize: none;"
                        placeholder="在此输入要发送的内容,可以是字符串(如:你好,世界!),也可以是HEX(如:49544c4447)"></textarea>
                    <div
                        class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-1 pb-1 mb-1 flex-shrink-0">
                        <div class="btn-toolbar">
                            <div class="form-check align-self-center me-2">
                                <input class="form-check-input" type="checkbox" id="serial-add-crlf">
                                <label class="form-check-label" for="serial-add-crlf">
                                    末尾加回车换行
                                </label>
                            </div>
                            <div class="form-check align-self-center me-2">
                                <input class="form-check-input" type="checkbox" id="serial-hex-send">
                                <label class="form-check-label" for="serial-hex-send">
                                    HEX发送
                                </label>
                            </div>
                            <div class="form-check align-self-center me-2">
                                <input class="form-check-input" type="checkbox" id="serial-loop-send">
                                <label class="form-check-label" for="serial-loop-send">
                                    循环发送
                                </label>
                            </div>
                            <div class="input-group input-group-sm">
                                <span class="input-group-text">发送间隔(MS)</span>
                                <input type="number" id="serial-loop-send-time" class="form-control" placeholder="" min="1"
                                    value="1000" style="width: 100px;" />
                            </div>
                        </div>
                        <button id="serial-send" class="btn btn-primary h-10 px-5"><i class="bi bi-send"></i>
                            发送</button>
                    </div>
                </div>
            </div>
            <div class="clear"></div>
            <div id="serial-tools" class="col-auto m-0 bg-light sidebar">
                <button class="toggle-button float-start" title="隐藏/打开边栏">
                    <i class="bi bi-chevron-compact-right"></i>
                </button>
                <div class="collapse show p-1 float-start overflow-hidden" style="width:428px">

                    <nav>
                        <div class="nav nav-tabs" id="nav-tab" role="tablist">
                            <button class="nav-link active" id="nav-quick-send-tab" data-bs-toggle="tab"
                                data-bs-target="#nav-quick-send" type="button" role="tab" aria-controls="nav-quick-send"
                                aria-selected="true">快捷发送</button>
                            <button class="nav-link" id="nav-options-tab" data-bs-toggle="tab" data-bs-target="#nav-options"
                                type="button" role="tab" aria-controls="nav-options" aria-selected="false">系统选项</button>
                        </div>
                    </nav>
                    <div class="tab-content pt-2 flex-fill" id="nav-tabContent">
                        <div class="tab-pane fade show active" id="nav-quick-send" role="tabpanel"
                            aria-labelledby="nav-quick-send-tab">
                            <div class="btn-toolbar">
                                <div class="flex-grow-1 input-group input-group-sm me-2">
                                    <span class="input-group-text">选择分组</span>
                                    <select class="form-select" id="serial-quick-send">
                                    </select>
                                </div>

                                <div class="btn-group">
                                    <button class="btn btn-sm btn-outline-secondary"
                                        id="serial-quick-send-add-group">新增</button>
                                    <button class="btn btn-sm btn-outline-secondary"
                                        id="serial-quick-send-rename-group">改名</button>
                                    <button class="btn btn-sm btn-outline-secondary"
                                        id="serial-quick-send-remove-group">删除</button>
                                </div>
                            </div>
                            <div class="d-flex mt-2">
                                <button id="serial-quick-send-add" class="btn btn-sm btn-outline-secondary me-5"><i
                                        class="bi bi-plus-square"></i> 增加一条</button>
                                <button class="btn btn-sm btn-outline-secondary me-2 flex-grow-1"
                                    id="serial-quick-send-import-btn"><i class="bi bi-folder-plus"></i>
                                    导入</button>
                                <input type="file" id="serial-quick-send-import" style="display: none;"
                                    accept="application/json" />
                                <button class="btn btn-sm btn-outline-secondary flex-grow-1"
                                    id="serial-quick-send-export"><i class="bi bi-folder-symlink"></i>
                                    导出</button>
                            </div>
                            <div class="mt-2">
                                <div class="d-flex">
                                    <span class="me-2 ms-3">移除</span>
                                    <span class="flex-grow-1 me-1">发送内容,点击修改,双击改名</span>
                                    <span class="flex-shrink-0 me-3">显示名称</span>
                                    <span class="flex-shrink-0 me-2">HEX</span>
                                </div>
                            </div>
                            <div id="serial-quick-send-content"
                                class="flex-grow-1 border border-2 p-2 rounded overflow-auto">
                            </div>
                        </div>
                        <div class="tab-pane fade" id="nav-options" role="tabpanel" aria-labelledby="nav-options-tab">
                            <h5>系统配置</h5>
                            <button class="btn btn-sm btn-outline-secondary me-2" id="serial-reset"><i
                                    class="bi bi-arrow-repeat"></i> 重置参数</button>
                            <button class="btn btn-sm btn-outline-secondary me-2" id="serial-export"><i
                                    class="bi bi-folder-symlink"></i> 导出配置</button>
                            <button class="btn btn-sm btn-outline-secondary me-2" id="serial-import"><i
                                    class="bi bi-folder-plus"></i> 导入配置</button>
                            <input type="file" id="serial-import-file" style="display: none;" accept="application/json" />
                        </div>
                    </div>
                </div>
            </div>
        </div>



        <div class="modal fade" id="model-tip" aria-hidden="true" tabindex="-1">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-header">
                        <h1 class="modal-title fs-5" id="modal-title"></h1>
                        <button class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body" id="modal-message">
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-primary" data-bs-dismiss="modal">好的</button>
                    </div>
                </div>
            </div>
        </div>

        <div class="modal fade" id="model-change-name" tabindex="-1" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h1 class="modal-title fs-5">名称</h1>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <form>
                            <div class="mb-3">
                                <label for="model-new-name" class="col-form-label">请输入新的名字:</label>
                                <input type="text" class="form-control" id="model-new-name">
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" id="model-save-name">保存</button>
                    </div>
                </div>
            </div>
        </div>
        <script src="js/serial.js"></script>

    </body>

</html>